package it.crudity.core.dao;

import it.crudity.core.model.BaseEntity;

import java.io.Serializable;

public interface DaoRepository {
	/***
	 * Gets the dao for the specified entity class. The esult may be a specific
	 * implementation or a {@link GenericDao} implementation
	 * 
	 * @param <T>
	 *            Entity class
	 * @param <ID>
	 *            Entity Id class
	 * @param clazz
	 *            Entity class
	 * @return Entity dao. It may be a specific implementation if present.
	 */
	public <T extends BaseEntity<ID>, ID extends Serializable> GenericDao<T, ID> getDaoForEntityClass(Class<T> clazz);

	/***
	 * Gets the dao for the specified entity instance. The result may be a
	 * specific implementation or a {@link GenericDao} implementation
	 * 
	 * @param <T>
	 *            Entity class
	 * @param <ID>
	 *            Entity Id class
	 * @param object
	 *            Entity instance
	 * @return Entity dao. It may be a specific implementation if present.
	 */
	public <T extends BaseEntity<ID>, ID extends Serializable> GenericDao<T, ID> getDaoForEntityInstance(T object);

	/***
	 * Gets the dao implementation of the given interface.
	 * 
	 * @param <D>
	 *            Dao interface class
	 * @param <T>
	 *            Entity class
	 * @param <ID>
	 *            Entity id class
	 * @param daoClass
	 *            Dao interface class
	 * @return Entity dao specific implementation.
	 */
	public <D extends GenericDao<T, ID>, T extends BaseEntity<ID>, ID extends Serializable> D getDaoByDaoInterface(
			Class<D> daoClass);
}
